<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

     <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 

  <script type="text/javascript">
  $(document).ready(function(){
	    $("#accordion").accordion();
	/*    $("#beforeReBtn").click(function(){
		   $.ajax({
			  type:"post",
			  url:"${initParam.root }message.do",
			  dataType:"json",
			  data:"command=messageBox2&pageRe=${requestScope.info.receivedList.pagingBean.startPageOfPageGroup-1 }&pageSd=1",
			  success:function(result){
				  alert(result.info.receivedList.list[0].senderId);
				 
				  $("#otherTableReSpage").html("넌왜거기있니");
				  //$("#otherTableReSpage").html("aaaa");
			  }
		   });
	   }); *///이전 버튼 클릭
	  });
  </script>
  <style type="text/css">
	#accordion{
		width: 750px
	}
	
</style>
<title>Insert title here</title>

</head>
<body>

	<form id="newMessageForm" action="message.do" method="post">
	<input type="submit" value="새로운 메세지 보내기">
	<input type="hidden" name="command" value="goNewMessage">
	</form>	
<br>
	<div id="accordion">
<h3>받은메세지</h3>
<div>
<p>
<table border="1">
	<tr>
		<th>보낸사람</th><th>보낸시간</th><th>내용</th>
	</tr>
	
<!-- 	<span id="otherTableReSpage"> -->
	<c:forEach items="${requestScope.info.receivedList.list }" var="list">
	<tr>
		<td>${list.senderId }</td><td width="200">${list.send_date }</td><td width="350"><a href="${initParam.root}message.do?command=viewOneMessage&no=${list.no}">${list.content }</a></td>
	</tr>
	</c:forEach>	
<!-- 	</span> -->
	
	</table>
 <c:set var="flag" value="${requestScope.info.receivedList.pagingBean.previousPageGroup }"></c:set>
<c:set var="next" value="${requestScope.info.receivedList.pagingBean.nextPageGroup }"></c:set>
<center>
 <c:if test="${flag==true }">
 	<a href="${initParam.root }message.do?command=messageBox&pageRe=${requestScope.info.receivedList.pagingBean.startPageOfPageGroup-1 }&pageSd=1">
 	이전
 	</a> 
 	<!-- <input type="button" id="beforeReBtn" value="이전"> -->
 </c:if>

 
 <c:forEach var="i" begin="${requestScope.info.receivedList.pagingBean.startPageOfPageGroup }" end="${requestScope.info.receivedList.pagingBean.endPageOfPageGroup }">
		<c:choose>
			<c:when test="${i == requestScope.info.receivedList.pagingBean.nowPage }">
				${i }
			</c:when>
			<c:otherwise>
				<a href="${initParam.root }message.do?command=messageBox&pageRe=${i }&pageSd=1">${i}</a>
			</c:otherwise>
		</c:choose>
</c:forEach>

 <c:if test="${next==true}">
			<a href="${initParam.root }message.do?command=messageBox&pageRe=${requestScope.info.receivedList.pagingBean.endPageOfPageGroup+1}&pageSd=1">
			다음</a>
</c:if>
</center>
</p>
</div>

<h3>보낸 메세지</h3>
<div>
<p>
<table border="1">
	<tr>
		<th>받는사람</th><th>보낸시간</th><th>내용</th>
	</tr>
	<c:forEach items="${requestScope.info.sendedList.list }" var="list2">
	<tr>
		<td>${list2.receiverId }</td><td width="200">${list2.send_date }</td><td width="350"><a href="${initParam.root}message.do?command=viewOneMessage&no=${list2.no}">${list2.content }</a></td>
	</tr>
	</c:forEach>	
	</table>
<c:set var="flag2" value="${requestScope.info.sendedList.pagingBean.previousPageGroup }"></c:set>
<c:set var="next2" value="${requestScope.info.sendedList.pagingBean.nextPageGroup }"></c:set>
<hr>
<center>
 <c:if test="${flag2==true }">
 	<a href="${initParam.root }message.do?command=messageBox&pageSd=${requestScope.info.sendedList.pagingBean.startPageOfPageGroup-1 }&pageRe=1">
 	이전
 	</a>
 </c:if>
	
	 <c:forEach var="i" begin="${requestScope.info.sendedList.pagingBean.startPageOfPageGroup }" end="${requestScope.info.sendedList.pagingBean.endPageOfPageGroup }">
		<c:choose>
			<c:when test="${i == requestScope.info.sendedList.pagingBean.nowPage }">
				${i }
			</c:when>
			<c:otherwise>
				<a href="${initParam.root }message.do?command=messageBox&pageSd=${i }&pageRe=1">${i}</a>
			</c:otherwise>
		</c:choose>
</c:forEach>

	
	 <c:if test="${next2==true}">
			<a href="${initParam.root }message.do?command=messageBox&pageSd=${requestScope.info.sendedList.pagingBean.endPageOfPageGroup+1}&pageRe=1">
			다음</a>
	</c:if>
		</center>
</p>

	</div>
</div>
